﻿<Window x:Class="ShoeBoxScan.MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:DiagramDesigner" xmlns:src="clr-namespace:RGSamples" xmlns:local="clr-namespace:ShoeBoxScan.Properties" xmlns:shoe="clr-namespace:ShoeBoxScan" xmlns:validation="clr-namespace:ValidationFramework;assembly=ValidationFramework" Title="ShoeBoxScan" Height="547" Width="554" src:GlassEffect.IsEnabled="True" MinHeight="450" MinWidth="480" Closing="Window_Closing" Loaded="Window_Loaded" MouseLeftButtonDown="Window_MouseLeftButtonDown" Icon="/ShoeBoxScan;component/Resources/app.png">
  <Window.Resources>
    <ResourceDictionary>
      <ResourceDictionary.MergedDictionaries>
        <ResourceDictionary Source="Resources/DesignerItem.xaml" />
      </ResourceDictionary.MergedDictionaries>

      <local:Settings x:Key="settings" />
      <Storyboard x:Key="showTray">
        <!--<ThicknessAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="tray" Storyboard.TargetProperty="(FrameworkElement.Margin)">
                <SplineThicknessKeyFrame KeyTime="00:00:00" Value="0,0,4,20"/>
                <SplineThicknessKeyFrame KeyTime="00:00:00.5000000" Value="0,0,4,-95" KeySpline="0,0,0,1"/>
            </ThicknessAnimationUsingKeyFrames>-->
        <DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="tray" Storyboard.TargetProperty="(UIElement.Opacity)">
          <SplineDoubleKeyFrame KeyTime="00:00:00" Value="0" />
          <SplineDoubleKeyFrame KeyTime="00:00:00.5000000" Value="1" />
        </DoubleAnimationUsingKeyFrames>
      </Storyboard>
      <Storyboard x:Key="hideTray">
        <!--<ThicknessAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="tray" Storyboard.TargetProperty="(FrameworkElement.Margin)">
                <SplineThicknessKeyFrame KeyTime="00:00:00" Value="0,0,4,-95"/>
                <SplineThicknessKeyFrame KeySpline="1,0,1,1" KeyTime="00:00:00.5000000" Value="0,0,4,20"/>
            </ThicknessAnimationUsingKeyFrames>-->
        <DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="tray" Storyboard.TargetProperty="(UIElement.Opacity)">
          <SplineDoubleKeyFrame KeyTime="00:00:00" Value="1" />
          <SplineDoubleKeyFrame KeyTime="00:00:00.5000000" Value="0" />
        </DoubleAnimationUsingKeyFrames>
      </Storyboard>
      <Style TargetType="{x:Type TextBox}" x:Key="TextBoxErrorStyle">
        <Setter Property="Validation.ErrorTemplate">
          <Setter.Value>
            <ControlTemplate>
              <DockPanel LastChildFill="True">
                <TextBlock DockPanel.Dock="Right" Foreground="Red" FontSize="12pt">*</TextBlock>
                <Border BorderBrush="Red" BorderThickness="2" CornerRadius="5">
                  <AdornedElementPlaceholder></AdornedElementPlaceholder>
                </Border>
              </DockPanel>
            </ControlTemplate>
          </Setter.Value>
        </Setter>
        <Style.Triggers>
          <Trigger Property="Validation.HasError" Value="true">
            <Setter Property="ToolTip" Value="{Binding RelativeSource={RelativeSource Self},
                Path=(Validation.Errors)[0].ErrorContent}" />
          </Trigger>
        </Style.Triggers>
      </Style>
    </ResourceDictionary>
  </Window.Resources>
  
  <Grid DataContext="{StaticResource settings}">
    <Grid x:Name="top" Margin="0,0,0,128">
      <Canvas x:Name="DesignerCanvas" Margin="12,12,108,7" ClipToBounds="True" SnapsToDevicePixels="True">
        <Image x:Name="imgScan" Source="{Binding  Path=MainSourceImage, RelativeSource = {RelativeSource FindAncestor, AncestorType={x:Type shoe:MainWindow} }}" />
      </Canvas>
      <Button Height="23" Margin="0,0,8,7" Name="btnScanNow" VerticalAlignment="Bottom" Click="btnScanNow_Click" HorizontalAlignment="Right" Width="94" IsDefault="True">1: Scan</Button>
      <Button Height="23" HorizontalAlignment="Right" Margin="0,161,8,0" Name="button1" VerticalAlignment="Top" Width="75" Click="button1_Click">Button</Button>
      <Button Height="23" HorizontalAlignment="Right" Name="button2" VerticalAlignment="Bottom" Width="94" Margin="0,0,8,36" Click="button2_Click">Fakescan</Button>
      <Image Height="70" HorizontalAlignment="Right" Margin="0,0,12,81" Name="testImage" Stretch="Fill" VerticalAlignment="Bottom" Width="70" />
    </Grid>
    <Grid x:Name="tray" VerticalAlignment="Bottom" Height="129" Opacity="1" Background="{x:Null}">
      <Label Height="23" HorizontalAlignment="Left" Margin="12,0,0,10" Name="label1" VerticalAlignment="Bottom" Width="55" VerticalContentAlignment="Center">Save in:</Label>
      <TextBox x:Name="selectedFolder" Margin="73,0,141,11" MouseDoubleClick="selectedFolder_MouseDoubleClick" Height="22" VerticalAlignment="Bottom">
        <TextBox.Text>
          <Binding Path="Default.SelectedFolder">
            <Binding.ValidationRules>
              <validation:RequiredValidationRule ErrorMessage="Please select a folder!" />
            </Binding.ValidationRules>
          </Binding>
        </TextBox.Text>
      </TextBox>
      <Button Height="23" HorizontalAlignment="Right" Margin="0,0,108,10" Name="ChooseFolder" VerticalAlignment="Bottom" Width="27" Click="ChooseFolder_Click">...</Button>
      <Button Height="23" HorizontalAlignment="Right" Margin="0,0,8,10" Name="SaveAll" VerticalAlignment="Bottom" Width="94" Click="SaveAll_Click" IsEnabled="True" Content="2: Save"/>
      <TextBlock Margin="12,8,6,54" Name="label2" TextWrapping="Wrap"><Bold>Pick a starting filename.</Bold> For example, if you put in "foo" you'll get pictures called "foo1" and "foo2" and so on. Don't worry, we'll never overwrite or delete an existing photo.</TextBlock>
      <TextBox Margin="120,0,108,42" Name="startingFileName" Height="22" VerticalAlignment="Bottom">
        <TextBox.Text>
          <Binding Path="Default.StartingFileName">
            <Binding.ValidationRules>
              <validation:RequiredValidationRule ErrorMessage="Please enter a Starting Filename!" />
            </Binding.ValidationRules>
          </Binding>
        </TextBox.Text>
      </TextBox>
      <Label HorizontalAlignment="Left" Margin="12,63,0,34" Name="label3" VerticalContentAlignment="Top" Width="114">Starting filename:</Label>
    </Grid>
  </Grid>


</Window>
